# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=liquidsfz
pkgver=0.3.1
pkgrel=1
pkgdesc="SFZ Sampler"
arch=(loong64 x86_64)
url="https://github.com/swesterfeld/liquidsfz"
license=(LGPL2.1)
groups=(lv2-plugins pro-audio)
depends=(gcc-libs glibc)
makedepends=(jack libsndfile lv2)
checkdepends=(lv2lint)
optdepends=(
  'jack: for standalone application'
  'lv2-host: for LV2 plugin'
)
provides=(libliquidsfz.so soundfont-synthesizer)
options=(debug)
source=(
  $pkgname-$pkgver.tar.gz::https://github.com/swesterfeld/${pkgname}/archive/${pkgver}.tar.gz
)
sha512sums=('00f020d7c649ab5a1d495666eb45326f9d59f278f261c5440987f82e08a7e2d5f1b3cfd4bfbf360a9a97ee2c7cbf3ccc9e29596c7b00488d0a2398d4fb5c90d6')
b2sums=('f6be2c40ea4ce2dfc70e7559e5ecb3a07151267048665d857bc21dad47dda04de0b7f491b61ac0da2f98a7429e88344ffe9756881b45bc5af969e67fb5814a43')

prepare() {
  cd $pkgname-$pkgver
  autoreconf -fiv
}

build() {
  cd $pkgname-$pkgver
  ./configure \
    --prefix=/usr \
    --enable-shared \
    --disable-static \
    --disable-static-cxx
  # prevent excessive overlinking due to libtool
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  make -k check -C $pkgname-$pkgver
  LD_LIBRARY_PATH="$pkgname-$pkgver/lib/.libs/:$LD_LIBRARY_PATH" lv2lint -Mpack -I $pkgname-$pkgver/lv2 "http://spectmorph.org/plugins/liquidsfz"
}

package() {
  depends+=(libsndfile.so)

  make DESTDIR="$pkgdir/" install -C $pkgname-$pkgver
  install -vDm 644 $pkgname-$pkgver/{NEWS,TODO,{OPCODES,README}.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
